// 日期区间
 laydate.render({
     elem: '#startDate'
 });
// 车辆选择
$('#sel-car').on('click',()=>{
    layer.open({
        type: 2,
        area: ['900px', '500px'],
        fixed: false, //不固定
        maxmin: true,
        content: "{:url('html/car/models')}"
      });
})

var page = 1;
var pagenum = 10;
var fi=1;
var url={
    list:"{:url('adminapi/MaintenanceRecord/maintenanceList')}",
    delete:"{:url('adminapi/driver/delete')}",
}
var main=[[ //表头
     {type:'checkbox', fixed: 'left'}
    ,{field: 'name', title: '编号',  sort: true, fixed: 'left'}
    ,{field: 'phone', title: '车牌号'}
    ,{field: 'company_name', title: '开始时间'}  
    ,{field: 'driving_age', title: '结束时间'}
    ,{field:'star', title:'地点'}
    ,{field:'work_state2', title:'送维/送保人'}
    ,{field:'state2', title:'项目'}
    ,{ title: '操作',width:180, toolbar:'#demo',fixed: 'right'}
]];
var data={};
data.page=page;
data.pagenum=pagenum;

//var where_json.work_state ={};
// {if $Think.get.car_id}
// where_json.work_state=['in','{$Think.get.car_id}']
// {/if}
// {if $Think.get.order_start}
// 		where_json.apply_time=['between time',['{$Think.get.order_start}','{$Think.get.order_end}']]
// {/if}
// where_json = JSON.stringfig(where_json)

ajaxsevice(data);
function ajaxsevice(data) {
    Load();
    //请求数据
    ajax(url.list, data, 'post').done(function (resp) {
        Load(1);
        // 成功回调
        //方法级表单渲染
        console.log(resp)
        table.render({
            elem: '#LAY_table_user',
            cols: main,
            data: resp.data,
            limit: pagenum,
            cellMinWidth: 80
        });
        if(fi==1){
            laypage.render({
                elem: 'page'
                ,count: resp.count
                ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                ,jump: function(obj, first){
                    console.log(obj)
                    if(!first){
                        page=obj.curr;
                        data.page=page;
                        pagenum=obj.limit;
                        data.pagenum=pagenum;
                        ajaxsevice(data);
                    }else{
                        
                    }
                }
              })
              fi = 2;
        }
        table.on('tool(demo)', function(obj){
            var data1 = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
           
            if(layEvent === 'edit'){ 

            }else if(layEvent==='del'){

            }
        })
    }).fail(function (err) {
        // 失败回调
        Load(1)
    	Err('请求失败')
    });

};